// 登录界面背景图动画
import bgAnimation from './bgAnimation'
// 模态框
import modal from './modal'

/* 
  Home页
*/
// 1-1 司南排行榜
import Sinan from './sinan'
// 1-2 金字塔
import Pyramid from './pyramid'
// 1-3 无缝滚动
import Seamless from './seamless'
const components = {
  bgAnimation,
  modal,
  Sinan,
  Pyramid,
  Seamless,
}

const install = (Vue = {}) => {
  // 定义一个标志 看当前组件是否已经注册
  if (install.installed) return
  // 遍历注册
  Object.keys(components).forEach((item) => {
    Vue.component(components[item].name, components[item])
  })
  // 注册完毕置installed为true
  install.installed = true
}

// 默认为false
install.installed = false

// Vue存在时
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
  install.installed = true
}
// 暴露
export default {
  ...components,
  install,
}
